function getReaderCardInfo() {
    $.ajax({
        url : '/reader/getReaderCardInfo',
        type : 'POST',
        success : function (res) {
            $("#jsId").text(res?.jsId || "");
            $("#period").text(res?.period || "");
            $("#readId").text(res?.readId || "");
        },
        error : function () {
            alert("请求出错");
        }
    })
}

document.addEventListener("DOMContentLoaded", function () {
    var readId = $("#readId").text();
    var input = document.getElementById("inputreadId");
    input.value = readId;
});

$("#btn-delete").click(function (event) {
    event.preventDefault();
    var readId = $("#inputreadId").val();
    $.ajax({
        url: "/reader/deleteReaderCard",
        type: "POST",
        data: {
            readId: readId
        },
        success: function (res) {
            if(res === 'success'){
                alert("注销成功");
                getReaderCardInfo();
            }else if(res === 'notExist'){
                alert("借阅证不存在");
                getReaderCardInfo();
            }else{
                alert("注销失败,请联系管理员");
            }
        },
        error: function () {
            alert("请求失败");
        }
    })
})



